home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
RTF
/
space.h
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
4KB
|
165 lines
/* $Header: /usr/people/pcd/Src/RTF/RCS/space.h,v 1.1 92/11/23 12:58:52 pcd Exp Locker: pcd $
*/
#ifndef __space_h
#define __space_h
typedef long TextPosition;
/*
* A TextPosition p separates an array of bytes into the
* bytes before p and the bytes after p. There is no
* bytes "at p." TextPosition 0 is before all the bytes.
*/
typedef int Coord;
/*
* Coord are used to measure and place text.
* Coords < 0 are off the page.
*/
typedef double Inches;
/*
* Inches are used to measure physical dimensions.
* The conversion between a Coord and an Inch is
* determined by the View class.
*/
class BRect{
/* a rectangle in quadrant 1
*/
public:
BRect(Coord ix=0, Coord iy=0, Coord iw=0, Coord ih=0)
/* USE : assert(ix>=0 && iy >= 0 && iw >= 0 && ih >= 0);
* brect = new BRect(ix, iy, iw, ih);
******/
{ x = ix; y = iy; width_ = iw; height_ = ih; };
int operator==(const BRect& other)
{ return x == other.x && y == other.y
&& width_ == other.width_ && height_ == other.height_; };
int operator<=(const BRect& other)
/* USE : if(br1 <= br2) // then br1 is a subset of br2
******/
{ return left() >= other.left() && right() <= other.right()
&& top() >= other.top() && bottom() <= other.bottom(); };
Coord height(Coord h)
/* USE : assert(h>=0);
* brect.height(h);
* assert(brect.height() == h);
******/
{ return height_ = h; };
Coord height() const
/* USE : assert(brect.height() >= 0);
******/
{ return height_; };
Coord width() const
/* USE: assert(brect.width() >= 0);
*/
{ return width_; };
Coord top() const
/* USE: assert(brect.top() >= 0 && brect.top()<=brect.bottom());
*/
{ return y; };
Coord inc_top(Coord dy)
/* USE: assert(dy >= -brect.top());
* brect.inc_top(dy);
*/
{ return y+=dy; };
Coord bottom() const
/* USE: assert(brect.bottom() >= 0 && brect.bottom()>=brect.top());
*/
{ return y+height_; };
Coord left() const
/* USE: assert(brect.left() >= 0 && brect.left()<=brect.right());
*/
{ return x; };
Coord right() const
/* USE: assert(brect.right() >= 0 && brect.right()>=brect.left());
*/
{ return x+width_; };
protected:
Coord x, y, width_, height_;
};
struct Point{
Coord x,y;
};
class Extent{
/*
* An Extent is three horizontal and two vertical coordinates:
*
* x0 aka width
* x1 aka current_x aka left
* x2 aka right
*
* y0 aka ascent aka top
* y1 aka descent aka bottom
*/
public:
Extent(Coord a=0, Coord b=0, Coord c=0, Coord d=-1, Coord e=-1)
{ x0 = a; x1 = b; x2 = c; y0 = d; y1 = e; };
void make_bad()
{ x0 = -1; };
int bad() const
{ return x0 < 0; };
Coord current_x(Coord cx)
{ return x1 = cx; };
Coord current_x() const
{ return x1; };
Coord move(Coord dx)
{ return x1 += dx; };
void max_ascent(Coord ma)
{ if (ma > ascent()) y0 = ma; };
void max_descent(Coord md)
{ if (md > descent()) y1 = md; };
Coord width() const
{ return x0; };
Coord left() const
{ return x1; };
Coord right(Coord r)
{ return x2 = r; };
Coord right() const
{ return x2; };
Coord top() const
{ return y0; };
Coord bottom() const
{ return y1; };
Coord ascent() const
{ return y0; };
Coord ascent(Coord a)
{ return y0 = a; };
Coord descent() const
{ return y1; };
Coord descent(Coord d)
{ return y1=d; };
Coord height() const
{ return ascent()+descent(); };
Coord x0, x1, x2;
Coord y0, y1;
};
#endif